#include <stm32f1xx.h>
#include <init.h>

// 测试背光
void testLight()
{
    // LCD背光闪烁10次,每次1秒
    for (int i = 0; i < 10; i++)
    {
        // 将PC13 LED背光引脚电平拉高,延时1秒，然后拉低
        WRITE_REG(GPIOC->BSRR, GPIO_BSRR_BS13);
        delay(500);
        WRITE_REG(GPIOC->BRR, GPIO_BRR_BR13);
        delay(500);
        dbLog("Begin Light %d\n", i);
    }

    dbLog("Begin Light %f\n", 0.99);

    uint8_t lightOn = 0;
    for (;;)
    {
        lightOn++;
        if (lightOn % 2)
        {
            WRITE_REG(GPIOC->BSRR, GPIO_BSRR_BS13);
        }
        else
        {
            WRITE_REG(GPIOC->BRR, GPIO_BRR_BR13);
        }
        dbLog("Loop Light %d\n", lightOn);
        delay(50);
    }
}

int main()
{
    init();

    dbLog("\nStart...\n");

    testLight();

    return 0;
}